home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 4,401 to 4,500 / aol-file-protocol-4400-4401-to-4500.zip / AOLDLs / PDA-Newton Development / ND Ruler 1.3.5 / Ruler 1.3.5 Ä.sit / Ruler 1.3.5 ƒ / Ruler 1.3.5 Readme next >
Text File  |  1994-07-29  |  16KB  |  342 lines

  1. Ruler
  2.  
  3. A Programmer's Tool
  4.  
  5.  
  6. Version 1.3.5
  7. July 29, 1994
  8.  
  9. ⌐ 1994, Digital Objectives
  10. All Rights Reserved
  11.  
  12.  
  13. John Dunning
  14. Digital Objectives
  15. 1661 Route 22 West
  16. Bound Brook, NJ  08805
  17.  
  18. Internet: jdunning@phoenix.princeton.edu
  19.  
  20.  
  21. DISTRIBUTION
  22.  
  23. This application is distributed as MailWare: if you use it and like it, 
  24. drop me a note (email or snail mail).  If you don't like it, tell me why 
  25. and how I can make it better.
  26.  
  27. You may freely use and distribute copies of this software as long as you 
  28. don't alter it or this documentation in any way and don't charge for its 
  29. use (the MacHack '94 CD excepted).
  30.  
  31.  
  32. DISCLAIMER
  33.  
  34. This software comes completely without any warranty.  Use it at your own 
  35. risk.  If bad things happen to you or your Newton as a result of using 
  36. this software, I'll feel sorry, but that's the extent of my liability. 
  37.  
  38.  
  39. INSTALLATION 
  40.  
  41. Install ruler as you would any other Newton application.  It requires 
  42. 46,060 bytes.  The first time its run, ruler will create a preferences 
  43. entry in the System soup, if there isn't one already.  The entry has the 
  44. tag "Ruler:DigObj", in case you ever want to remove it.
  45.  
  46.  
  47. NOTE
  48.  
  49. This utility is intended primarily for developers using NTK or 
  50. BookMaker.  If you're not a developer, you probably won't find it of much 
  51. use. 
  52.  
  53.  
  54. OVERVIEW
  55.  
  56. If you've used the Newton ToolKit for any amount of time, you'll quickly 
  57. find that the layout display in the current version has a number of 
  58. bugs.  Views which are not justified from their parent's left and top 
  59. edges will not appear in the correct position when displayed in NTK, 
  60. although they'll be fine on the Newton.  Positioning these views where
  61. you want them generally requires that you fiddle with them in NTK, 
  62. compile the project, download it to the Newton, check the view's position, 
  63. and so on through the cycle, until you get it right.
  64.  
  65. That process isn't unbearable, but what makes it even harder is that 
  66. there's been no easy way to determine a view's position on the Newton.  
  67. If two views don't quite line up, you've got to squint and try to count 
  68. the pixels to figure out how far they should be moved in NTK.  Recently a 
  69. screen-capture capability has been added to NTK, so you could also 
  70. capture the Newton screen, paste it into a graphics application like 
  71. Photoshop and count the pixels there.  But that's also cumbersome.
  72.  
  73. Ruler is intended to simply this process.  It's a little utility that 
  74. displays two crosshairs on the Newton screen.  Their position, and the 
  75. distance between them, is displayed on a floating palette.   You can 
  76. position the crosshairs by dragging them with the pen.  That's 
  77. pretty much all it does, but it does it well.
  78.  
  79.  
  80. MOVING THE CROSSHAIRS
  81.  
  82. Using Ruler is quite simple.  Tapping its icon in the Extras Drawer 
  83. opens a wide, narrow floating palette.  From left to right, there's a 
  84. standard scroller, two outlined X/Y displays, one width/height display, 
  85. and a group of four buttons.
  86.  
  87. When the palette is open, tapping anywhere on the screen (other than on the 
  88. palette, of course) will move the active crosshair to the point you tapped.  
  89. If the active crosshair isn't visible, it'll appear where you tapped.  
  90. Dragging the pen across the screen will move the crosshair continuously.  
  91. You cannot move it outside the visible bounds of the screen (except under 
  92. certain conditions described below).
  93.  
  94. The crosshair's current X and Y coordinates are continuously displayed in 
  95. its readout on the palette.  If a position display shows two dashes instead 
  96. of numbers, that means the crosshair has not been positioned yet.  Tap on 
  97. the screen to position it.
  98.  
  99. Besides tapping and dragging, you can also position the crosshair using the 
  100. scroller.  Tapping on any of the four arrows on the scroller will move the 
  101. crosshair one pixel in that direction.  The crosshair will move 
  102. continuously if you hold down the pen.  By tapping on the scroller and 
  103. dragging the pen away from it, you can increase the speed at which the 
  104. crosshair moves.  The farther you move the pen from the scoller, the faster 
  105. the crosshair will move.
  106.  
  107. The crosshair is XOR'd against the screen, which means that it will 
  108. appear white where it crosses a black pixel on the screen, and black 
  109. where it crosses a white pixel.
  110.  
  111. You can have two crosshairs on the screen at once.  Each has a position 
  112. display on the palette.  There can be only one active crosshair on the 
  113. screen at a time.  The active crosshair is drawn in solid black lines, and 
  114. its display is outlined in black.  The inactive crosshair is drawn in 
  115. grey, with a grey-outlined display.  Tapping on the screen or using the 
  116. scroller will always move the active crosshair; the inactive one will 
  117. stay where it is.
  118.  
  119. To make an inactive crosshair active, tap on its display on the palette.  
  120. The display will highlight, its outline will turn black, and the 
  121. crosshair will also turn black.  The currently active crosshair will turn 
  122. grey and become inactive.  
  123.  
  124. If you tap on the active display, it will become inactive, so that both 
  125. crosshairs are inactive.  When this happens, the crosshairs behave a little 
  126. differently.  Tapping on the scroller will move the crosshairs together, so 
  127. they'll maintain their relative positions.  If you tap on the screen, the 
  128. top left corner of the box formed by the crosshairs will move to the point 
  129. you tapped.  Dragging will move the crosshairs as a unit.  If you drag the 
  130. crosshairs off the screen, their coordinates will be clipped to the visible 
  131. bounds of the screen.  But as long as you don't lift the pen, you can drag 
  132. them back.  If you do lift the pen, the crosshairs will move so that 
  133. they're visible on the screen, changing their relative positions.
  134.  
  135. Note that if you align the crosshairs horizontally or vertically and 
  136. inactivate them both, the aligned horizontal or vertical portions of the 
  137. crosshairs will disappear.  If you don't want this to happen, offset the 
  138. crosshairs by one pixel, or activate one of them.  
  139.  
  140.  
  141. WIDTH/HEIGHT DISPLAY
  142.  
  143. When both crosshairs are visible, the width and height of the square they 
  144. form, in pixels, is displayed on the third readout, the one with no 
  145. border.
  146.  
  147. There is a second mode for this readout.  Tapping on the button with a 
  148. diamond on it will display a popup menu.  Two of the options on the menu 
  149. are "Measure pixels" and "Measure offset."  Selecting "Measure offset" will 
  150. change the W/H display to an X/Y display.  This mode is discussed in more 
  151. detail below.
  152.  
  153.  
  154. BUTTONS
  155.  
  156. There is a group of four buttons on the right end of the palette.  The 
  157. bottom right button is the standard close box.  Tapping it quits Ruler.
  158.  
  159. The top right button (a tiny square) toggles between the full-size palette 
  160. and an iconified mode.  In the iconified mode, the crosshairs are hidden 
  161. and the palette shrinks to a tiny square, which can be repositioned by 
  162. dragging on its grey border.  Tapping on the single button in the iconified 
  163. palette will return it to its full size and to its position before it was 
  164. iconified.  
  165.  
  166. After you open Ruler, you'll usually want to shrink the palette.  If you 
  167. don't, you won't be able to open the application you want to measure 
  168. because the crosshair layer covers the entire screen.  Once the application 
  169. is open, expand the palette to its full size and start measuring.
  170.  
  171. The top left button (a vertical or horizontal line) toggles the palette 
  172. between a vertical and horizontal orientation.  When you change its 
  173. orientation, the palette will move so it doesn't hang off the edge of the 
  174. screen after it has rotated.
  175.  
  176. The bottom left button (a diamond) pops up a menu of the following options: 
  177.     About Ruler: displays an about box for Ruler.
  178.     
  179.     Print local box: 
  180.         prints a viewBounds frame to the Inspector, if it's connected.  Since 
  181.         this is a local box, the left and top values will be 0, and the right 
  182.         and bottom ones will be the width and height of the box formed by the 
  183.         crosshairs.
  184.     
  185.     Print global box: 
  186.         prints a viewBounds frame to the Inspector, if it's connected.  The 
  187.         frame will contain the global bounds of the box formed by the crosshairs.
  188.  
  189.     Print view origin: 
  190.         prints a frame containing left and top coordinates to the Inspector, if 
  191.         it's connected.  To calculate these points, Ruler assumes the second
  192.         crosshair is positioned on the view's origin and the first is 
  193.         positioned on the origin of the view's parent (or sibling, if it's 
  194.         sibling justified).  This function is discussed in more detail below.
  195.  
  196.     Measure pixels:
  197.     Measure offset:
  198.         these two options determine what information the third (unoutlined) 
  199.         display shows.  In the default position, the display will show the 
  200.         width and height, in pixels, of the box formed by the two crosshairs.  
  201.         If only one crosshair has been set, two dashes will be shown instead.
  202.         
  203.         Selecting "Measure offset" will cause the display to show the offset 
  204.         from the first crosshair to the second, in x,y coordinates.  In this 
  205.         mode you will also be able to drag the crosshairs off the right and 
  206.         bottom edges of the screen (coordinates 240 and 320 or 336, 
  207.         respectively).  The only other difference in these two settings is that 
  208.         the pixel values will always be positive and will be one greater than 
  209.         the offset values.  
  210.         
  211.         It's necessary to have these two options to handle the case where, for 
  212.         instance, the x coordinate of the first crosshair is 4 and the x 
  213.         coordinate of the second is 2.  In this example, the crosshairs span 
  214.         3 pixels, but the offset is -2.
  215.     
  216.     Open iconified: 
  217.         selecting this option will cause Ruler to always open in the collapsed, 
  218.         iconified mode.  You will probably want to leave this item checked, 
  219.         because the application you want to measure will likely be covered by 
  220.         the Extras Drawer after you open Ruler.  To close the Extras Drawer, 
  221.         you'll have to iconify Ruler, so this option saves you a step.
  222.  
  223.  
  224. POSITIONING THE PALETTE
  225.  
  226. To move the palette around the screen, you can drag it by its grey border.  
  227. Another good way to drag the palette is to put the pen on the width/height 
  228. display, which is easier to hit than the border.  When the palette is 
  229. iconified, you can also drag it by its grey border.
  230.  
  231. Ruler remembers the positions of the full-sized palette and the iconified 
  232. palette separately.  This is useful if you want the iconified palette to 
  233. always move to the bottom right corner of the screen, for instance.
  234.  
  235. While you are dragging the palette, the crosshairs will disappear.  They 
  236. will reappear when you stop dragging.  This is normal.  
  237.  
  238. If your Newton goes to sleep while Ruler is open, it will be iconified 
  239. the next time you turn the Newton on.  It's necessary to do this to keep 
  240. the screen from turning white when you switch the Newton back on. 
  241.  
  242.  
  243. USES FOR RULER
  244.  
  245. One of the simplest ways to use Ruler is to make sure that two or more 
  246. views are aligned horizontally or vertically.  With one crosshair, you 
  247. can just eyeball the alignment.  With two, you can use the "Measure 
  248. offset" option to show how much the view bounds need to be changed to 
  249. bring the views into alignment.
  250.  
  251. With the "Measure pixels" option, it's a snap to measure the width and 
  252. height of a bitmap, assuming there's no extra white space around it, 
  253. which obviously won't show up on a white background.
  254.  
  255. There are some subtleties to measuring views which you should be aware of.  
  256. If you want to measure the width and height of a view, you must position 
  257. the crosshairs just *inside* the view's border, because borders are drawn 
  258. outside a view's bounds.  Remember also that a border can have an inset 
  259. value.  If the inset is white, it may look like the border is narrower than 
  260. it really is.  The matte border style, for instance, has a 1-pixel white 
  261. inset, so its full width is 6 pixels, even though only 5 are taken up by 
  262. the grey and black lines.  To measure a protoFloater view then, you should 
  263. leave one pixel of white space between the crosshairs and the inner grey 
  264. border.
  265.  
  266. You can make sure several views are the same size or are evenly spaced by 
  267. deactivating both crosshairs.  Position them so that the box they form is 
  268. the size you want.  Then tap the active crosshair's display, so that both 
  269. displays are outlined in grey, not black.  You can now drag the 
  270. crosshairs as a unit and position them anywhere on the screen to check 
  271. that other views are the same size or separated by the same amount.
  272.  
  273. It's possible to measure the offset of a view from its parent, assuming 
  274. both it and its parents borders are visible.  However, the view's 
  275. justification values can complicate this procedure.  The best way to see 
  276. this is to load the ViewTest package, which should have been included 
  277. with Ruler.  (Note that this package was created on a MP0, so it might 
  278. be messed up a little on a MP110.)
  279.  
  280. First open Ruler, iconify it, open ViewTest, then expand Ruler and check 
  281. the "Measure offset" option.  ViewTest simply displays a few views with 
  282. single pixel borders.  Each view shows its bounds and its justification 
  283. values (P = parent, S = sibling, L = left, R = right, T = top, B = bottom).
  284.  
  285. The top view is justified from its parent's top and left edges, and its 
  286. parent's origin is at (0,0).  To find its top and left bounds, position 
  287. the first crosshair at the view's parent's origin (the top, left corner 
  288. of the screen) and position the second crosshair at the view's origin, 
  289. just inside the border.  The third display, now labeled X/Y, will show 
  290. the view's origin, (47,42).  Not a terribly interesting example.
  291.  
  292. The second view is more exciting.  It's also parent-justified left and top, 
  293. but it's sibilng-justified left and bottom.  Its sibling is the first view, 
  294. so you need to position the first crosshair on that view's bottom, left 
  295. corner (which is its origin, as far as the sibling view is concerned).  
  296. However, because of the way view bounds relate to screen pixels, you must 
  297. put the first crosshair *on* the view's bottom border, not inside of it, 
  298. although it should still be inside the left border.  Then put the second 
  299. crosshair on the sibling view's origin.  The  X/Y display should show 
  300. (10,20).  
  301.  
  302. This special case also applies to the right edge.  So whenever a view is 
  303. justified to its parent's or sibling's bottom and/or right edge, you must 
  304. position the first crosshair directly on the parent's or sibling's bottom 
  305. and/or right edge.  You can see this with the bottommost view in ViewTest.  
  306. It is parent-justified right and bottom.  It's parent is the app's base 
  307. view, and the app view fills the entire screen.  Since its border is 
  308. off-screen, you must set the first crosshair just off-screen, at (240,336 
  309. or 320).  This is why you can drag the crosshairs off the bottom and right 
  310. edges of the screen in "Measure offset" mode.
  311.  
  312. Play around with ViewTest until you are comfortable with determining the 
  313. top and left bounds of a view.
  314.  
  315.  
  316. CAVEATS
  317.  
  318. It is possible to measure floating views with Ruler, but since the view 
  319. floats, it is above the crosshair layer.  The crosshairs will be drawn over 
  320. the floating view, but the view will be "live," i.e., you can't tap on it 
  321. to position a crosshair.  You can, however, tap somewhere else on the 
  322. screen and drag the crosshair over the floating view.  Once you stop 
  323. dragging, you'll need to use the scroller to position the crosshair 
  324. further.
  325.  
  326. Closing a floating view while Ruler is expanded will leave a white square 
  327. where the view used to be.  To restore the screen, iconify and expand the 
  328. palette.  You can do this whenever there's garbage on the screen that 
  329. doesn't seem to go away.
  330.  
  331. Be careful of where you tap to dismiss the popup menu on systems earlier 
  332. than 1.3.  Since the crosshair layer is hidden while the popup menu is 
  333. open, whatever is underneath will receive the tap.
  334.  
  335. If things get really messed up, it is possible for the Ruler palette to 
  336. be closed while the crosshair layer is still open.  Tapping on the screen 
  337. should throw an exception, which should cause the crosshair layer to 
  338. close itself.  If things get really, really messed up, the crosshair 
  339. layer might be closed but the screen might not update, so that it looks 
  340. like nothing happened but you can hear the Extras Drawer open and close, 
  341. etc.  In this case, you have to reset the Newton.
  342.